<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<title>6.270 - JoyOS: motor.h File Reference</title>
	<link href="main.css" media="screen" rel="Stylesheet" type="text/css"/>
	<link href="doxygen.css" rel="stylesheet" type="text/css">
</head>  
<body>
	<div id="header">
		<div id="headerb">
		<div id="headtext">
			<span class="titletext">AUTONOMOUS ROBOT DESIGN COMPETITION</span>
			6.270
		</div>
		<div class="mainmenu">
			<a href="http://web.mit.edu/6.270/www">Home</a>
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/about/">About</a> 
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/sponsors/">Sponsors</a>
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/contests/">Past Contests</a> 
		 	&bull;
			<a href="http://web.mit.edu/6.270/www/contestants/">Contestant Information</a>
		</div>
	</div>
	</div>

<div class="maincontent">
<!-- Generated by Doxygen 1.5.6 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>motor.h File Reference</h1>Motor Outputs. <a href="#_details">More...</a>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="motor_8h.html#a2a5af0fb9c1fa2047a5ca0af110f806">motor_init</a> (void)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="motor_8h.html#b129f1d1311c35f2231e413a029c7eda">motor_set_vel</a> (uint8_t motor, int16_t vel)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="motor_8h.html#26af94f53f119bff06198c1d26f041af">motor_brake</a> (uint8_t motor)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">uint16_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="motor_8h.html#6cf2eaff2bd38c883fc704be138fd1b4">motor_get_current</a> (uint8_t motor)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">uint16_t&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="motor_8h.html#6933136c2a2ef41ced912821e9a06469">motor_get_current_MA</a> (uint8_t motor)</td></tr>

</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
The happyboard as 6 1.5A Motor drivers with current sensing capabilities. Motors can be set to 3 possible states: <em>drive</em>, <em>coast</em>, or <em>brake</em>.<p>
<ul>
<li><em>Drive</em> is the default state, used for any velocity other than 0</li><li><em>Coast</em> is used when a motor is set to 0 velocity. This causes the motor to coast to a stop (the motor is not actively stopped).</li><li><em>Brake</em> is used when motorBrake is called, and actively stops the motor by shorting the motor terminals.</li></ul>
<p>
Each motor port has a current sensor associated with it, allowing the robot to sense the current usage of each motor. Motor current increases proportional to torque and thus can be used to sense when a motor has stalled (driving into a wall, other robots, etc). <hr><h2>Function Documentation</h2>
<a class="anchor" name="26af94f53f119bff06198c1d26f041af"></a><!-- doxytag: member="motor.h::motor_brake" ref="26af94f53f119bff06198c1d26f041af" args="(uint8_t motor)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void motor_brake           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>motor</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set a motor to brake (stops the motor as quickly as possible). Calling motorSetVel() again will disable the brake state.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>motor</em>&nbsp;</td><td>Motor port to brake. </td></tr>
  </table>
</dl>

</div>
</div><p>
<a class="anchor" name="6cf2eaff2bd38c883fc704be138fd1b4"></a><!-- doxytag: member="motor.h::motor_get_current" ref="6cf2eaff2bd38c883fc704be138fd1b4" args="(uint8_t motor)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t motor_get_current           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>motor</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read the current in a given motor.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>motor</em>&nbsp;</td><td>Motor to sense current of. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the current of motor 'motor'. </dd></dl>

</div>
</div><p>
<a class="anchor" name="6933136c2a2ef41ced912821e9a06469"></a><!-- doxytag: member="motor.h::motor_get_current_MA" ref="6933136c2a2ef41ced912821e9a06469" args="(uint8_t motor)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t motor_get_current_MA           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>motor</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Read the current in a given motor in milliamps.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>motor</em>&nbsp;</td><td>Motor to sense current of. </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the current of motor 'motor', in milliamps. </dd></dl>

</div>
</div><p>
<a class="anchor" name="a2a5af0fb9c1fa2047a5ca0af110f806"></a><!-- doxytag: member="motor.h::motor_init" ref="a2a5af0fb9c1fa2047a5ca0af110f806" args="(void)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void motor_init           </td>
          <td>(</td>
          <td class="paramtype">void&nbsp;</td>
          <td class="paramname">          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Initialize motors. Should not be called by user. 
</div>
</div><p>
<a class="anchor" name="b129f1d1311c35f2231e413a029c7eda"></a><!-- doxytag: member="motor.h::motor_set_vel" ref="b129f1d1311c35f2231e413a029c7eda" args="(uint8_t motor, int16_t vel)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void motor_set_vel           </td>
          <td>(</td>
          <td class="paramtype">uint8_t&nbsp;</td>
          <td class="paramname"> <em>motor</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int16_t&nbsp;</td>
          <td class="paramname"> <em>vel</em></td><td>&nbsp;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Set the motor velocity of a specific motor. The sign of 'vel' determines direction. A value of 0 sets the motor to coast.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>motor</em>&nbsp;</td><td>Motor port to set. </td></tr>
    <tr><td valign="top"></td><td valign="top"><em>vel</em>&nbsp;</td><td>Velocity to set motor 'motor'. </td></tr>
  </table>
</dl>

</div>
</div><p>
</div>
</div>
<div class="maincontent">
	<div class="footer centre">
		<hr>
		Generated on Sun Jan 18 22:59:34 2009 by&nbsp;<a href="http://www.doxygen.org/index.html">Doxygen</a> 1.5.6<br/>
		6.270 Staff, 2008 | 
		<a href="mailto:6.270-organizers@mit.edu">Contact Us</a> | 
		<a href="http://web.mit.edu">MIT</a>
	</div>
</div>
</body>
</html>
